﻿using Android.Bluetooth;
using Android.OS;
using Java.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SnakeRemote.Services.BluetoothService
{
    internal sealed class BluetoothDeviceInfo : IBluetoothDeviceInfo
    {
        private readonly BluetoothDevice device;
        public IEnumerable<UUID> Uuids
            => device.GetUuids().Select(id => id.Uuid);
        public string Address => device.Address;
        public string Name => device.Name;
        public string Alias
        {
            get
            {
                if (Build.VERSION.SdkInt >= BuildVersionCodes.R)
#pragma warning disable CA1416 // 验证平台兼容性
                    return device.Alias;
#pragma warning restore CA1416 // 验证平台兼容性
                else
                    return device.Name;
            }
        }
        public BluetoothDeviceInfo(BluetoothDevice device)
        {
            this.device = device;
        }

        public override string ToString()
        {
            return $"{Alias} {Address}";
        }
    }
}
